<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:th="http://www.thymeleaf.org">
<head th:replace="_header_include::frag(~{::title},~{::style},~{})">
    <title>我的客户</title>
    <style>
        button a{color:#fff!important;}
        /*.formItem,.formItem .el-form-item__content{width:100%}*/
        .el-select,.el-date-editor{width: 100%!important;}
    </style>
</head>
<body>

<div id="mainDiv" class="mainPadding" style="display: none;">
    <template>
        <el-breadcrumb separator="/" class="elBreadcrumb marginB20">
            <el-breadcrumb-item>Home</el-breadcrumb-item>
            <el-breadcrumb-item>商务管理</el-breadcrumb-item>
            <el-breadcrumb-item>我的客户（商务）</el-breadcrumb-item>
        </el-breadcrumb>

        <div class="mainSearchBg">
            <div v-show="showVisitAduitDatas.oneShow" class="marginB10" style="overflow: hidden;">
                <div class="marginB10">
                    <span class="fs14" style="margin-right: 10px;">首次到访</span>  
                    <el-button size="medium" type="primary" @click="openEditVisitRecord">添加到访记录</el-button>
                </div>                
                <el-table :data="showVisitAduitDatas.one" style="width: 100%" tooltip-effect="dark" border ref="multipleTable" class="marginB10">
                    <el-table-column prop="customerName" label="客户姓名" align="center" width="110"></el-table-column>
                    <el-table-column prop="projectName" label="考察项目" align="center"></el-table-column>
                    <el-table-column prop="companyName" label="考察公司" align="center"></el-table-column>
                    <el-table-column prop="vistitTime" label="到访时间" :formatter="formatVisitTime" align="center" width="130"></el-table-column>
                    <el-table-column prop="signProvince" label="预签约省份" align="center" width="100"></el-table-column>
                    <el-table-column prop="signCity" label="预签约市" align="center"></el-table-column>
                    <el-table-column prop="signDistrict" label="预签约区/县" align="center"></el-table-column>
                    <el-table-column prop="vistitStoreTypeName" label="到访店铺类型" align="center" width="110"></el-table-column>
                    <el-table-column prop="visitType" label="到访类型" align="center" width="80">
                        <template slot-scope="scope">
                            <div v-if="scope.row.visitType === 1">
                                预约来访
                            </div>
                            <div v-else-if="scope.row.visitType === 2">
                                慕名来访
                            </div>
                            <div v-else-if="scope.row.visitType === 3">
                                临时来访
                            </div>
                        </template>
                    </el-table-column>
                    <el-table-column prop="arrVisitCity" label="到访城市" align="center"></el-table-column>
                    <el-table-column prop="visitPeopleNum" label="到访人数" align="center" width="80"></el-table-column>
                    <el-table-column prop="createTime" label="创建时间" align="center" width="150"></el-table-column>
                    <el-table-column prop="createUserName" label="创建人"   width="100"  align="center"></el-table-column>
                    <el-table-column prop="isSign" label="是否签约" align="center" width="80">
                        <template slot-scope="scope">
                            <div v-if="scope.row.isSign === 0">
                                否
                            </div>
                            <div v-else-if="scope.row.isSign ===1">
                                是
                            </div>
                        </template>
                    </el-table-column>
                    <el-table-column prop="status" label="到访有效性" align="center" width="100">
                        <template slot-scope="scope">
                            <div v-if="scope.row.status === 1">
                                审核中
                            </div>
                            <div v-else-if="scope.row.status ===2">
                                有效
                            </div>
                            <div v-else-if="scope.row.status ===0">
                                无效
                            </div>
                        </template>
                    </el-table-column>
                </el-table>
                <p v-show="showVisitAduitDatas.oneNotSignShow" style = "color: #1e2746;margin-bottom: 10px;">未签约原因：{{showVisitAduitDatas.oneNotSignReason}}</p>
                <p v-show="showVisitAduitDatas.oneRebutShow"  style = "color:red;margin-bottom: 10px;">驳回原因：{{showVisitAduitDatas.oneRebutReason}}</p>
            </div>

            <div v-show="showVisitAduitDatas.twoShow" class="marginB10" style="overflow: hidden;">
                <div class="marginB10">
                    <span class="fs14">2次到访</span>  
                </div>
                <!-- <el-button size="mini"  type="text" style = "color: #1e2746">2次到访</el-button> -->
                <el-table :data="showVisitAduitDatas.two" style="width: 100%" tooltip-effect="dark" border ref="multipleTable" class="marginB10">
                    <el-table-column prop="customerName" label="客户姓名" align="center" width="110"></el-table-column>
                    <el-table-column prop="projectName" label="考察项目" align="center"></el-table-column>
                    <el-table-column prop="companyName" label="考察公司" align="center"></el-table-column>
                    <el-table-column prop="vistitTime" label="到访时间" :formatter="formatVisitTime" align="center" width="130"></el-table-column>
                    <el-table-column prop="signProvince" label="预签约省份" align="center" width="100"></el-table-column>
                    <el-table-column prop="signCity" label="预签约市" align="center"></el-table-column>
                    <el-table-column prop="signDistrict" label="预签约区/县" align="center"></el-table-column>
                    <el-table-column prop="vistitStoreTypeName" label="到访店铺类型" align="center" width="110"></el-table-column>
                    <el-table-column prop="visitType" label="到访类型" align="center" width="80">
                        <template slot-scope="scope">
                            <div v-if="scope.row.visitType === 1">
                                预约来访
                            </div>
                            <div v-else-if="scope.row.visitType === 2">
                                慕名来访
                            </div>
                            <div v-else-if="scope.row.visitType === 3">
                                临时来访
                            </div>
                        </template>
                    </el-table-column>
                    <el-table-column prop="arrVisitCity" label="到访城市" align="center"></el-table-column>
                    <el-table-column prop="visitPeopleNum" label="到访人数" align="center" width="80"></el-table-column>
                    <el-table-column prop="createTime" label="创建时间" align="center" width="150"></el-table-column>
                    <el-table-column prop="createUserName" label="创建人"   width="100"  align="center"></el-table-column>
                    <el-table-column prop="isSign" label="是否签约" align="center" width="80">
                        <template slot-scope="scope">
                            <div v-if="scope.row.isSign === 0">
                                否
                            </div>
                            <div v-else-if="scope.row.isSign ===1">
                                是
                            </div>
                        </template>
                    </el-table-column>
                    <el-table-column prop="status" label="到访有效性" align="center" width="100">
                        <template slot-scope="scope">
                            <div v-if="scope.row.status === 1">
                                审核中
                            </div>
                            <div v-else-if="scope.row.status ===2">
                                有效
                            </div>
                            <div v-else-if="scope.row.status ===0">
                                无效
                            </div>
                        </template>
                    </el-table-column>
                </el-table>
                <p  v-show="showVisitAduitDatas.twoNotSignShow"  style = "color: #1e2746;margin-bottom: 10px;">未签约原因：{{showVisitAduitDatas.twoNotSignReason}}</p>
                <p v-show="showVisitAduitDatas.twoRebutShow" style = "color: red;margin-bottom: 10px;">驳回原因：{{showVisitAduitDatas.twoRebutReason}}</p>
            </div>

            <div v-show="showVisitAduitDatas.threeShow" class="marginB10" style="overflow: hidden;">
                <div class="marginB10">
                    <span class="fs14">多次到访</span>  
                </div>
                <!-- <el-button size="mini"  type="text" style = "color: #1e2746">多次到访</el-button> -->
                <el-table :data="showVisitAduitDatas.three" style="width: 100%" tooltip-effect="light" border ref="multipleTable" class="marginB10">
                    <el-table-column prop="customerName" label="客户姓名" align="center" width="110"></el-table-column>
                    <el-table-column prop="projectName" label="考察项目" align="center"></el-table-column>
                    <el-table-column prop="companyName" label="考察公司" align="center"></el-table-column>
                    <el-table-column prop="vistitTime" label="到访时间" :formatter="formatVisitTime" align="center" width="130"></el-table-column>
                    <el-table-column prop="signProvince" label="预签约省份" align="center" width="100"></el-table-column>
                    <el-table-column prop="signCity" label="预签约市" align="center"></el-table-column>
                    <el-table-column prop="signDistrict" label="预签约区/县" align="center"></el-table-column>
                    <el-table-column prop="vistitStoreTypeName" label="到访店铺类型" align="center" width="110"></el-table-column>
                    <el-table-column prop="visitType" label="到访类型" align="center" width="80">
                        <template slot-scope="scope">
                            <div v-if="scope.row.visitType === 1">
                                预约来访
                            </div>
                            <div v-else-if="scope.row.visitType === 2">
                                慕名来访
                            </div>
                            <div v-else-if="scope.row.visitType === 3">
                                临时来访
                            </div>
                        </template>
                    </el-table-column>
                    <el-table-column prop="arrVisitCity" label="到访城市" align="center"></el-table-column>
                    <el-table-column prop="visitPeopleNum" label="到访人数" align="center" width="80"></el-table-column>
                    <el-table-column prop="createTime" label="创建时间" align="center" width="150"></el-table-column>
                    <el-table-column prop="createUserName" label="创建人"   width="100"  align="center"></el-table-column>
                    <el-table-column prop="isSign" label="是否签约" align="center" width="80">
                        <template slot-scope="scope">
                            <div v-if="scope.row.isSign === 0">
                                否
                            </div>
                            <div v-else-if="scope.row.isSign ===1">
                                是
                            </div>
                        </template>
                    </el-table-column>
                    <el-table-column prop="notSignReason" label="未签约原因"  width="200"  show-overflow-tooltip="true" align="center"></el-table-column>
                    <el-table-column prop="rebutReason" label="驳回原因"  width="200"   show-overflow-tooltip="true" align="center"></el-table-column>

                    <el-table-column prop="status" label="到访有效性" align="center" width="100">
                        <template slot-scope="scope">
                            <div v-if="scope.row.status === 1">
                                审核中
                            </div>
                            <div v-else-if="scope.row.status ===2">
                                有效
                            </div>
                            <div v-else-if="scope.row.status ===0">
                                无效
                            </div>
                        </template>
                    </el-table-column>
                </el-table>
                <!--<p v-show="showVisitAduitDatas.threeNotSignShow" style = "color: #1e2746">未签约原因：{{showVisitAduitDatas.threeNotSignReason}}</p><br>-->
                <!--<p v-show="showVisitAduitDatas.threeRebutShow" style = "color: red">驳回原因：{{showVisitAduitDatas.threeRebutReason}}</p>-->
            </div>
        </div>

        <!--添加到访记录-->
        <el-dialog title="添加到访记录" :visible.sync="addVisitRecordDialogVisible"  width="870px">
            <template>
                <el-form :model="addVisitRecord" ref="addVisitRecord" :rules="rules">
                    <el-row :gutter="20">
                        <el-col :span="10">
                            <el-form-item label="考察公司："  :label-width="formLabelWidth"  prop="companyid">
                                <el-select v-model="addVisitRecord.companyid" placeholder="考察公司"  clearable filterable >
                                    <el-option v-for="item in companyArr" :key="item.id" :label="item.companyName" :value="item.id"></el-option>
                                </el-select>
                            </el-form-item>
                        </el-col>

                        <el-col :span="10">
                            <el-form-item label="到访时间："    :label-width="formLabelWidth"  prop="vistitTime">
                                <el-date-picker v-model="addVisitRecord.vistitTime" format="yyyy-MM-dd HH:mm" type="datetime" placeholder="选择日期时间"></el-date-picker>
                            </el-form-item>
                        </el-col>
                    </el-row>

                    <el-row :gutter="20">
                        <el-col :span="10">
                            <el-form-item label="客户姓名："  :label-width="formLabelWidth"  prop="customerName" >
                                <el-input v-model="addVisitRecord.customerName" autocomplete="off"  maxlength="10"    ></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="10">
                            <el-form-item label="考察项目："    :label-width="formLabelWidth"  prop="projectId">
                                <el-select v-model="addVisitRecord.projectId" placeholder="请选择"  clearable filterable @change="getShopType">
                                    <el-option v-for="item in projectArr" :key="item.id" :label="item.projectName" :value="item.id"></el-option>
                                </el-select>
                            </el-form-item>
                        </el-col>
                    </el-row>

                    <el-row :gutter="20">
                        <el-col :span="10">
                            <el-form-item label="到访类型："  :label-width="formLabelWidth"  prop="visitType">
                                <el-select v-model="addVisitRecord.visitType"  clearable >
                                    <el-option v-for="item in visitTypeArr" :key="item.value" :label="item.name" :value="item.value"></el-option>
                                </el-select>
                            </el-form-item>
                        </el-col>
                        <el-col :span="10">
                            <el-form-item label="到访店铺类型："    :label-width="formLabelWidth"  prop="vistitStoreType">
                                <el-select v-model="addVisitRecord.vistitStoreType" placeholder="请选择"  clearable filterable>
                                    <el-option v-for="item in vistitStoreTypeArr" :key="item.value" :label="item.name" :value="item.value"></el-option>
                                </el-select>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row :gutter="20">
                        <el-col :span="10">
                            <el-form-item label="签约省份："  :label-width="formLabelWidth"  prop="signProvince"  >
                                <el-select v-model="addVisitRecord.signProvince" placeholder="请选择"  @change="changeVisitProvince" clearable filterable>
                                    <el-option v-for="item in provinceArr" :key="item.name" :label="item.name" :value="item.name"></el-option>
                                </el-select>
                            </el-form-item>
                        </el-col>
                        <el-col :span="10">
                            <el-form-item label="签约城市："    :label-width="formLabelWidth"  prop="signCity" >
                                <el-select v-model="addVisitRecord.signCity" placeholder="请选择"  @change="currentCity" clearable filterable>
                                    <el-option v-for="item in cityArr" :key="item.name" :label="item.name" :value="item.name"></el-option>
                                </el-select>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row :gutter="20">
                        <el-col :span="10">
                            <el-form-item label="签约区/县："  :label-width="formLabelWidth"  prop="signDistrict">
                                <el-select v-model="addVisitRecord.signDistrict" placeholder="请选择" clearable filterable >
                                    <el-option v-for="item in districtArr" :key="item.name" :label="item.name" :value="item.name"></el-option>
                                </el-select>
                            </el-form-item>
                        </el-col>
                        <el-col :span="10">
                            <!--<el-form-item label="到访城市："    :label-width="formLabelWidth"  prop="arrVisitCity">
                                <el-input v-model="addVisitRecord.arrVisitCity" autocomplete="off"  maxlength="50"    ></el-input>
                            </el-form-item>-->
                            <el-form-item label="到访城市" :label-width="formLabelWidth" prop="arrVisitCity">
                                <el-select v-model="addVisitRecord.arrVisitCity" placeholder="请选择" clearable
                                           style="width:100%">
                                    <el-option v-for="item in visitCityArr" :key="item.name" :label="item.name"
                                               :value="item.name"></el-option>
                                </el-select>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row :gutter="20">
                        <el-col :span="10">
                            <el-form-item label="是否签约："  :label-width="formLabelWidth"  prop="isSign" clearable >
                                <el-select v-model="addVisitRecord.isSign" placeholder="请选择" @change="showNotSignReason">
                                    <el-option v-for="item in isSignArr" :key="item.value" :label="item.name" :value="item.value"></el-option>
                                </el-select>
                            </el-form-item>
                        </el-col>
                        <el-col :span="10">
                            <el-form-item label="到访人数："    :label-width="formLabelWidth"  prop="visitPeopleNum">
                                <el-input v-model="addVisitRecord.visitPeopleNum" type="number" min="0"   oninput="if(value.length>2)value=value.slice(0,2)"  autocomplete="off"     ></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row :gutter="20" v-show="addVisitRecord.isSign==0">
                        <el-col :span="20">
                            <el-form-item label="未签约原因："  id="notSignReason" :label-width="formLabelWidth"  prop="notSignReason">
                                <el-input type="textarea" v-model="addVisitRecord.notSignReason"  maxlength="100" :rows="3" placeholder="请输入内容(限制100字)"></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                </el-form>

                <div slot="footer" class="dialog-footer">
                    <!--<el-button type="primary" id="goSignButton"   @click="goEditSign">去填写签约单</el-button>-->
                    <el-button type="primary" @click="saveVisitRecord" :disabled="addVisitAble">提交</el-button>
                    <el-button  @click="addVisitRecordDialogVisible = false">取消</el-button>
                </div>
            </template>
        </el-dialog>

        <el-dialog title="添加签约单信息" width="70%" :visible.sync="dialogFormSigningVisible">
            <template>
                <el-form :model="formSigning" ref="formSigning" >
                    <div class="paddB20">签约单信息</div>
                    <div>
                        <el-row>
                            <!--<el-col :span="10">-->
                                <!--<el-form-item label="签约单编号：" :label-width="formLabelWidth" prop="signNo">-->
                                    <!--<el-input v-model="formSigning.signNo" maxLength="20" ></el-input>-->
                                <!--</el-form-item>-->
                            <!--</el-col>-->
                            <el-col :span="10">
                                <el-form-item label="客户姓名：" :label-width="formLabelWidth" prop="customerName">
                                    <el-input v-model="formSigning.customerName"  maxLength="10"></el-input>
                                </el-form-item>
                            </el-col>
                            <el-col :span="10">
                                <el-form-item label="客户身份证号" :label-width="formLabelWidth" prop="idCard">
                                    <el-input v-model="formSigning.idCard"  maxLength="20" ></el-input>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>

                            <el-col :span="10">
                                <el-form-item label="客户联系电话：" :label-width="formLabelWidth" prop="phone">
                                    <el-input v-model="formSigning.phone" maxLength="11" ></el-input>
                                </el-form-item>
                            </el-col>
                            <el-col :span="10">
                                <el-form-item label="签约餐饮公司：" :label-width="formLabelWidth" prop="signCompanyId">
                                    <el-select v-model="formSigning.signCompanyId" clearable filterable placeholder="请选择签约餐饮公司">
                                        <el-option v-for="item in companyArr" :key="item.id" :label="item.companyName" :value="item.id"></el-option>
                                    </el-select>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>

                            <el-col :span="10">
                                <el-form-item label="签约项目：" :label-width="formLabelWidth" prop="signProjectId">
                                    <el-select v-model="formSigning.signProjectId"  clearable filterable  placeholder="请选择">
                                        <el-option v-for="item in projectArr" :key="item.id" :label="item.projectName" :value="item.id"></el-option>
                                    </el-select>
                                </el-form-item>
                            </el-col>
                            <el-col :span="10">
                                <el-form-item label="签约省份：" :label-width="formLabelWidth" prop="signProvince">
                                    <el-select v-model="formSigning.signProvince" placeholder="请选择签约省份" @change="currentProvince">
                                        <el-option v-for="item in provinceArr" :key="item.name" :label="item.name" :value="item.name"></el-option>
                                    </el-select>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>

                            <el-col :span="10">
                                <el-form-item label="签约城市：" :label-width="formLabelWidth" prop="signCity">
                                    <el-select v-model="formSigning.signCity" placeholder="请选择签约城市："  @change="currentCity">
                                        <el-option v-for="item in cityArr" :key="item.name" :label="item.name" :value="item.name"></el-option>
                                    </el-select>
                                </el-form-item>
                            </el-col>

                            <el-col :span="10">
                                <el-form-item label="签约区/县：" :label-width="formLabelWidth" prop="signDictrict">
                                    <el-select v-model="formSigning.signDictrict" placeholder="请选择签约区/县">
                                        <el-option v-for="item in districtArr" :key="item.name" :label="item.name" :value="item.name"></el-option>
                                    </el-select>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>

                            <el-col :span="10">
                                <el-form-item label="签约店型：" :label-width="formLabelWidth" prop="signShopType">
                                    <el-select v-model="formSigning.signShopType" placeholder="请选择">
                                        <el-option v-for="item in vistitStoreTypeArr" :key="item.value" :label="item.name" :value="item.value"></el-option>
                                    </el-select>
                                </el-form-item>
                            </el-col>
                            <el-col :span="10">
                                <el-form-item label="应收金额：" :label-width="formLabelWidth" prop="amountReceivable">
                                    <el-input v-model="formSigning.amountReceivable"  type="number" oninput="if(value.length>10)value=value.slice(0,10)"  onkeypress="return(/[\d]/.test(String.fromCharCode(event.keyCode)))" autocomplete="off" maxLength="10" style="width: 80%;"></el-input><span style="padding-left: 10px;">元</span>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>

                            <el-col :span="10">
                                <el-form-item label="路费（报首次）：" :label-width="formLabelWidth" prop="firstToll">
                                    <el-input v-model="formSigning.firstToll"  type="number" oninput="if(value.length>10)value=value.slice(0,10)"  onkeypress="return(/[\d]/.test(String.fromCharCode(event.keyCode)))" autocomplete="off" maxLength="10" style="width: 80%;"></el-input><span style="padding-left: 10px;">元</span>
                                </el-form-item>
                            </el-col>
                            <el-col :span="10">
                                <el-form-item label="优惠金额：" :label-width="formLabelWidth" prop="preferentialAmount">
                                    <el-input v-model="formSigning.preferentialAmount"  type="number" oninput="if(value.length>10)value=value.slice(0,10)"  onkeypress="return(/[\d]/.test(String.fromCharCode(event.keyCode)))" autocomplete="off" maxLength="10" style="width: 80%;"></el-input><span style="padding-left: 10px;">元</span>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>

                            <el-col :span="10">
                                <el-form-item label="签约类型：" :label-width="formLabelWidth" prop="signType">
                                    <el-select v-model="formSigning.signType" @change="selectSigningType" placeholder="请选择签约类型：">
                                        <el-option
                                                v-for="item in option2s"
                                                :key="item.value"
                                                :label="item.label"
                                                :value="item.value">
                                        </el-option>
                                    </el-select>
                                </el-form-item>
                            </el-col>
                            <el-col :span="10">
                                <el-form-item label="赠送金额：" :label-width="formLabelWidth" prop="giveAmount">
                                    <el-input v-model="formSigning.giveAmount"  type="number" oninput="if(value.length>10)value=value.slice(0,10)"  onkeypress="return(/[\d]/.test(String.fromCharCode(event.keyCode)))" autocomplete="off" maxLength="10" style="width: 80%;"></el-input><span style="padding-left: 10px;">元</span>
                                </el-form-item>
                            </el-col>
                        </el-row>
                    </div>
                    <div class="paddB20">付款明细</div>
                    <div>
                        <el-row>
                            <el-col :span="10">
                                <el-form-item label="付款类型：" :label-width="formLabelWidth" prop="payType">
                                    <el-select v-model="formSigning.payType" placeholder="请选择签约付款类型" disabled>
                                        <el-option  key="1" label="全款" value="1"></el-option>
                                        <el-option  key="2" label="定金" value="2"></el-option>
                                    </el-select>
                                </el-form-item>
                            </el-col>
                            <el-col :span="10">
                                <el-form-item label="付款方式：" :label-width="formLabelWidth" prop="payMode">
                                    <el-select v-model="formSigning.payMode" placeholder="请选择付款方式：">
                                        <el-option
                                                v-for="item in option3s"
                                                :key="item.value"
                                                :label="item.label"
                                                :value="item.value">
                                        </el-option>
                                    </el-select>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="10">
                                <el-form-item label="付款时间：" :label-width="formLabelWidth" prop="payTime">
                                    <el-date-picker
                                            type="date"
                                            format="yyyy-MM-dd"
                                            placeholder="选择日期"
                                            v-model="formSigning.payTime" style="width: 100%;"></el-date-picker>
                                </el-form-item>
                            </el-col>
                            <el-col :span="10">
                                <el-form-item label="实收金额：" :label-width="formLabelWidth" prop="amountReceived">
                                    <el-input  style="width: 80%;" v-model="formSigning.amountReceived"  type="number" oninput="if(value.length>10)value=value.slice(0,10)"  onkeypress="return(/[\d]/.test(String.fromCharCode(event.keyCode)))"></el-input>
                                    <span style="padding-left: 10px;">元</span>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row v-show="isAllMoney">
                            <el-col :span="10">
                                <el-form-item label="余款金额：" :label-width="formLabelWidth" prop="amountBalance">
                                    <el-input  style="width: 80%;" v-model="formSigning.amountBalance"  type="number" oninput="if(value.length>10)value=value.slice(0,10)"  onkeypress="return(/[\d]/.test(String.fromCharCode(event.keyCode)))"></el-input>
                                    <span style="padding-left: 10px;">元</span>
                                </el-form-item>
                            </el-col>
                            <el-col :span="10">
                                <el-form-item label="预计余款补齐时间：" :label-width="formLabelWidth" prop="makeUpTime">
                                    <el-date-picker
                                            type="date"
                                            format="yyyy-MM-dd"
                                            placeholder="选择日期"
                                            v-model="formSigning.makeUpTime"
                                            style="width: 100%;"></el-date-picker>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="10">
                                <el-form-item label="业绩金额：" :label-width="formLabelWidth" prop="amountPerformance">
                                    <el-input style="width: 80%;"  v-model="amountPerformance"  type="number" oninput="if(value.length>10)value=value.slice(0,10)"  onkeypress="return(/[\d]/.test(String.fromCharCode(event.keyCode)))"></el-input>
                                    <span style="padding-left: 10px;">元</span>
                                </el-form-item>
                            </el-col>
                        </el-row>
                    </div>
                </el-form>
                <div slot="footer" class="dialog-footer f-tac">
                    <el-button type="primary" :disabled="addVisitAble" @click="submitForm('formSigning')">提 交</el-button>
                    <el-button @click="dialogFormSigningVisible = false">取 消</el-button>
                </div>
            </template>
        </el-dialog>

        <el-dialog title="编辑签约单" width="70%" :visible.sync="dialogUpdateFormSigningVisible">
            <template>
                <el-form :model="updateFormSigning" ref="updateFormSigning" >
                    <el-form-item label="驳回时间："  :label-width="formLabelWidth">
                        <el-button size="mini"  type="text" style = "font-size: 17px;color: #1e2746">{{updateFormSigning.rebutTime}}</el-button>
                    </el-form-item>
                    <el-form-item label="驳回原因："  :label-width="formLabelWidth">
                        <span style="color: red; width:60%; word-wrap: break-word; word-break:break-all; ">{{updateFormSigning.rebutReason}}</span>
                        <!-- <el-button size="mini"  type="text"  style="color: red">{{updateFormSigning.rebutReason}}</el-button> -->
                    </el-form-item>
                    <div class="paddB20">签约单信息</div>
                    <div>
                        <el-row>
                            <el-col :span="10">
                                <el-form-item label="签约单编号：" :label-width="formLabelWidth" prop="signNo">
                                    <el-input :disabled="notEditRebutSign" v-model="updateFormSigning.signNo" maxLength="20" disabled></el-input>
                                </el-form-item>
                            </el-col>
                            <el-col :span="10">
                                <el-form-item label="客户姓名：" :label-width="formLabelWidth" prop="customerName">
                                    <el-input :disabled="notEditRebutSign" v-model="updateFormSigning.customerName"></el-input>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="10">
                                <el-form-item label="客户身份证号：" :label-width="formLabelWidth" prop="idCard">
                                    <el-input :disabled="notEditRebutSign" v-model="updateFormSigning.idCard"  maxLength="20" ></el-input>
                                </el-form-item>
                            </el-col>
                            <el-col :span="10">
                                <el-form-item label="客户联系电话：" :label-width="formLabelWidth" prop="phone">
                                    <el-input :disabled="notEditRebutSign" v-model="updateFormSigning.phone" maxLength="11" ></el-input>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="10">
                                <el-form-item label="签约餐饮公司：" :label-width="formLabelWidth" prop="signCompanyId">
                                    <el-select :disabled="notEditRebutSign" clearable filterable v-model="updateFormSigning.signCompanyId" placeholder="请选择签约餐饮公司">
                                        <el-option v-for="item in companyArr" :key="item.id" :label="item.companyName" :value="item.id"></el-option>
                                    </el-select>
                                </el-form-item>
                            </el-col>
                            <el-col :span="10">
                                <el-form-item label="签约项目：" :label-width="formLabelWidth" prop="signProjectId">
                                    <el-select :disabled="notEditRebutSign"  clearable filterable  v-model="updateFormSigning.signProjectId" placeholder="请选择">
                                        <el-option v-for="item in projectArr" :key="item.id" :label="item.projectName" :value="item.id"></el-option>
                                    </el-select>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="10">
                                <el-form-item label="签约省份：" :label-width="formLabelWidth" prop="signProvince">
                                    <el-select :disabled="notEditRebutSign" v-model="updateFormSigning.signProvince" placeholder="请选择签约省份" @change="currentProvince">
                                        <el-option v-for="item in provinceArr" :key="item.name" :label="item.name" :value="item.name"></el-option>
                                    </el-select>
                                </el-form-item>
                            </el-col>
                            <el-col :span="10">
                                <el-form-item label="签约城市：" :label-width="formLabelWidth" prop="signCity">
                                    <el-select :disabled="notEditRebutSign" v-model="updateFormSigning.signCity" placeholder="请选择签约城市："  @change="currentCity">
                                        <el-option v-for="item in cityArr" :key="item.name" :label="item.name" :value="item.name"></el-option>
                                    </el-select>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="10">
                                <el-form-item label="签约区/县：" :label-width="formLabelWidth" prop="signDictrict">
                                    <el-select :disabled="notEditRebutSign" v-model="updateFormSigning.signDictrict" placeholder="请选择签约区/县">
                                        <el-option v-for="item in districtArr" :key="item.name" :label="item.name" :value="item.name"></el-option>
                                    </el-select>
                                </el-form-item>
                            </el-col>
                            <el-col :span="10">
                                <el-form-item label="签约店型：" :label-width="formLabelWidth" prop="signShopType">
                                    <el-select :disabled="notEditRebutSign" v-model="updateFormSigning.signShopType" placeholder="请选择">
                                        <el-option v-for="item in vistitStoreTypeArr" :key="item.value" :label="item.name" :value="item.value"></el-option>
                                    </el-select>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="10">
                                <el-form-item label="应收金额：" :label-width="formLabelWidth" prop="amountReceivable">
                                    <el-input :disabled="notEditRebutSign"  v-model="updateFormSigning.amountReceivable"  type="number" oninput="if(value.length>10)value=value.slice(0,10)"  onkeypress="return(/[\d]/.test(String.fromCharCode(event.keyCode)))" autocomplete="off" maxLength="10" style="width: 80%;"></el-input><span style="padding-left: 10px;">元</span>
                                </el-form-item>
                            </el-col>
                            <el-col :span="10">
                                <el-form-item label="路费（报首次）：" :label-width="formLabelWidth" prop="firstToll">
                                    <el-input :disabled="notEditRebutSign"   v-model="updateFormSigning.firstToll"  type="number" oninput="if(value.length>10)value=value.slice(0,10)"  onkeypress="return(/[\d]/.test(String.fromCharCode(event.keyCode)))" autocomplete="off" maxLength="10" style="width: 80%;"></el-input><span style="padding-left: 10px;">元</span>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="10">
                                <el-form-item label="优惠金额：" :label-width="formLabelWidth" prop="preferentialAmount">
                                    <el-input :disabled="notEditRebutSign"  v-model="updateFormSigning.preferentialAmount"  type="number" oninput="if(value.length>10)value=value.slice(0,10)"  onkeypress="return(/[\d]/.test(String.fromCharCode(event.keyCode)))" autocomplete="off" maxLength="10" style="width: 80%;"></el-input><span style="padding-left: 10px;">元</span>
                                </el-form-item>
                            </el-col>
                            <el-col :span="10">
                                <el-form-item label="签约类型：" :label-width="formLabelWidth" prop="signType">
                                    <el-select :disabled="notEditRebutSign" v-model="updateFormSigning.signType" @change="selectUpdateSigningType" placeholder="请选择签约类型：">
                                        <el-option
                                                v-for="item in option2s"
                                                :key="item.value"
                                                :label="item.label"
                                                :value="item.value">
                                        </el-option>
                                    </el-select>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="10">
                                <el-form-item label="赠送金额：" :label-width="formLabelWidth" prop="giveAmount">
                                    <el-input :disabled="notEditRebutSign" v-model="updateFormSigning.giveAmount"  type="number" oninput="if(value.length>10)value=value.slice(0,10)"  onkeypress="return(/[\d]/.test(String.fromCharCode(event.keyCode)))" autocomplete="off" maxLength="10" style="width: 80%;"></el-input><span style="padding-left: 10px;">元</span>
                                </el-form-item>
                            </el-col>
                        </el-row>
                    </div>
                    <div class="paddB20">付款明细</div>
                    <div>
                        <el-row>
                            <el-col :span="10">
<!--                                <el-form-item label="付款类型：" :label-width="formLabelWidth" prop="payType">-->
<!--                                    <el-select v-model="updateFormSigning.payType" :disabled ="payTypeSelect" placeholder="请选择签约付款类型" >-->
<!--                                        &lt;!&ndash; <el-option  key="1" label="全款" value="1"></el-option>-->
<!--                                         <el-option  key="2" label="定金" value="2"></el-option>-->
<!--                                         <el-option  key="3" label="追加定金" value="3"></el-option>-->
<!--                                         <el-option  key="4" label="尾款" value="4"></el-option>&ndash;&gt;-->
<!--                                        <el-option-->
<!--                                                v-for="item in payTypeArr"-->
<!--                                                :key="item.value"-->
<!--                                                :label="item.label"-->
<!--                                                :value="item.value">-->
<!--                                        </el-option>-->
<!--                                    </el-select>-->
<!--                                </el-form-item>-->
                            </el-col>
                            <el-col :span="10">
                                <el-form-item label="付款方式：" :label-width="formLabelWidth" prop="payMode">
                                    <el-select v-model="updateFormSigning.payMode" placeholder="请选择付款方式：">
                                        <el-option
                                                v-for="item in option3s"
                                                :key="item.value"
                                                :label="item.label"
                                                :value="item.value">
                                        </el-option>
                                    </el-select>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="10">
                                <el-form-item label="付款时间：" :label-width="formLabelWidth" prop="payTime">
                                    <el-date-picker
                                            type="date"
                                            format="yyyy-MM-dd"
                                            placeholder="选择日期"
                                            v-model="updateFormSigning.payTime" style="width: 100%;"></el-date-picker>
                                </el-form-item>
                            </el-col>
                            <el-col :span="10">
                                <el-form-item label="实收金额：" :label-width="formLabelWidth" prop="amountReceived">
                                    <el-input maxLength="10" v-model="updateFormSigning.amountReceived" style="width: 80%;"  type="number" oninput="if(value.length>10)value=value.slice(0,10)"  onkeypress="return(/[\d]/.test(String.fromCharCode(event.keyCode)))"></el-input>
                                    <span style="padding-left: 10px;">元</span>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row v-show="isAllMoney">
                            <el-col :span="10">
                                <el-form-item label="余款金额：" :label-width="formLabelWidth" prop="amountBalance">
                                    <el-input maxLength="10" v-model="updateFormSigning.amountBalance" style="width: 80%;"  type="number" oninput="if(value.length>10)value=value.slice(0,10)"  onkeypress="return(/[\d]/.test(String.fromCharCode(event.keyCode)))"></el-input>
                                    <span style="padding-left: 10px;">元</span>
                                </el-form-item>
                            </el-col>
                            <el-col :span="10">
                                <el-form-item label="预计余款补齐时间：" :label-width="formLabelWidth" prop="makeUpTime">
                                    <el-date-picker
                                            type="date"
                                            format="yyyy-MM-dd"
                                            placeholder="选择日期"
                                            v-model="updateFormSigning.makeUpTime"
                                            style="width: 100%;"></el-date-picker>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="10">
                                <el-form-item label="业绩金额：" :label-width="formLabelWidth" prop="performanceAmount">
                                    <el-input maxLength="10" v-model="updateFormSigningAmountPerformance" style="width: 80%;"  type="number" oninput="if(value.length>10)value=value.slice(0,10)"  onkeypress="return(/[\d]/.test(String.fromCharCode(event.keyCode)))"></el-input>
                                    <span style="padding-left: 10px;">元</span>
                                </el-form-item>
                            </el-col>
                        </el-row>
                    </div>
                </el-form>
                <div slot="footer" class="dialog-footer f-tac">
                    <el-button type="primary" @click="submitUpdateForm('updateFormSigning')" :disabled="addVisitAble">提交</el-button>
                    <el-button @click="dialogUpdateFormSigningVisible = false">取 消</el-button>
                </div>
            </template>
        </el-dialog>

    </template>
    <!--添加到访记录-->



</div>

<!-- import common js-->
<div th:include="_footer_include :: #jsLib"></div>
<!--<script th:src="@{/js/excel/xlsx.min.js}" src="../static/js/excel/xlsx.min.js"></script>-->
<script th:inline="javascript">
    var clueId = [[${clueId}]];
    var busGroupId = '[[${busGroupId}]]';
    var visitStatus = [[${visitStatus}]];
    var signAuditStatus = [[${signAuditStatus}]];
    var proSelect=[[${proSelect}]];
    var companySelect=[[${companySelect}]];
    // 查询 模块
    var mainDivVM = new Vue({
        el: '#mainDiv',
        data: {
            formLabelWidth:"150px",
            addVisitAble:false,
            addVisitRecordDialogVisible:false,
            dialogUpdateFormSigningVisible:false,
            dialogFormSigningVisible:false,
            clueId:clueId,
            signArr:[{value:0,name:'未签约'},{value:1,name:'已签约'}],
            isSignArr:[{value:0,name:'否'},{value:1,name:'是'}],
            visitArr:[{value:0,name:'待处理'},{value:1,name:'未到访'},{value:2,name:'首次到访'},{value:3,name:'多次到访'}],
            visitTypeArr:[{value:1,name:'预约来访'},{value:2,name:'慕名来访'},{value:3,name:'临时来访'}],
            option2s: [{value: 1, label: '一次性全款'},{value: 2, label: '先交定金'}],
            option3s: [{value: '1', label: '现金'},{value: '2', label: 'POS'},{value: '3', label: '转账'},{value: '4', label: '微信'},{value: '5', label: '支付宝'}],
            payTypeArr1:[{value: "1", label: '全款'},{value: "2", label: '定金'},{value: "3", label: '追加定金'},{value: "4", label: '尾款'}],
            vistitStoreTypeArr:[],
            provinceArr:[],
            districtArr:[],
            cityArr:[],
            companyArr:[],
            visitCityArr:[],
            projectArr:proSelect,
            isAllMoney: false,
            notEditRebutSign:false,
            payTypeSelect:false,
            addVisitRecord:{
                clueId:clueId,
                companyid:"",
                vistitTime:null,
                customerName:"",
                projectId:"",
                visitType:1,
                vistitStoreType:"",
                signProvince:"",
                signCity:"",
                signDistrict:"",
                arrVisitCity:"",
                isSign:1,
                visitPeopleNum:"",
                notSignReason:""
            },
            showVisitAduitDatas:{
                one:[],
                two:[],
                three:[],
                oneNotSignReason:"",
                twoNotSignReason:"",
                threeNotSignReason:"",
                oneRebutReason:"",
                twoRebutReason:"",
                threeRebutReason:"",
                oneShow:true,
                twoShow:false,
                threeShow:false,

                oneRebutShow:false,
                twoRebutShow:false,
                threeRebutShow:false,
                oneNotSignShow:false,
                twoNotSignShow:false,
                threeNotSignShow:false
            },
            formSigning: {
                clueId:clueId,
                signNo:'',
                customerName: '',
                idCard: '',
                phone: '',
                signCompanyId:'',
                signProjectId: '',
                signProvince:'',
                signCity: '',
                signDictrict:'',
                signShopType:'',
                amountReceivable:'',
                firstToll:'',
                preferentialAmount:'',
                signType:1,
                giveAmount:'',

                payType:"1",
                payMode:'',
                amountReceived: '',
                amountBalance: '',
                makeUpTime:'',
                payTime: '',
                amountPerformance:''
            },
            updateFormSigning: {
                signId:"",
                clueId:"",
                signNo:'',
                customerName: '',
                idCard: '',
                phone: '',
                signCompanyId:'',
                signProjectId: '',
                signProvince:'',
                signCity: '',
                signDictrict:'',
                signShopType:'',
                amountReceivable:'',
                firstToll:'',
                preferentialAmount:'',
                signType:"1",
                giveAmount:'',
                rebutTime:"",
                rebutReason:"",

                payDetailId:"",
                payType:'1',
                payMode:'',
                amountReceived: '',
                amountBalance: '',
                makeUpTime:'',
                payTime: '',
                amountPerformance:''
            },
            rules:{
                companyid:[
                    { required: true, message: '请选择考察公司', trigger: 'change' }
                ],
                vistitTime:[
                    { required: true, message: '请选择到访时间', trigger: 'change' }
                ],
                projectId:[
                    { required: true, message: '请选择考察项目', trigger: 'change' }
                ],
                vistitStoreType:[
                    { required: true, message: '请选择到访店铺类型', trigger: 'change' }
                ],
                visitType:[
                    { required: true, message: '请选择到访类型', trigger: 'change' }
                ],
                // signDistrict:[
                //     { required: true, message: '请选择签约区/县', trigger: 'change' }
                // ],
                isSign:[
                    { required: true, message: '请选择是否签约', trigger: 'change' }
                ],
                customerName: [
                    { required: true, message: '请输入客户姓名', trigger: 'blur' }
                ],
                idCard: [
                    { required: true, message: '请输入客户身份证号', trigger: 'blur' }
                ],
                phone: [
                    { required: true, message: '请输入客户联系电话', trigger: 'blur' }
                ],
                signCompanyId: [
                    { required: true, message: '请选择签约餐饮公司', trigger: 'change' }
                ],
                signProjectId: [
                    { required: true, message: '请选择签约项目', trigger: 'change' }
                ],
                signProvince: [
                    { required: true, message: '请选择签约省份', trigger: 'change' }
                ],
                // signCity: [
                //     { required: true, message: '请选择签约城市', trigger: 'change' }
                // ],
                signDictrict: [
                    { required: true, message: '请选择签约区/县', trigger: 'change' }
                ],
                signShopType: [
                    { required: true, message: '请选择签约店型', trigger: 'change' }
                ],
                arrVisitCity: [ //请填写来访城市
                    { required: true, message: '请填写到访城市', trigger: 'change' }
                ],
                visitPeopleNum: [ //请填写到访人数
                    { required: true, message: '请填写到访人数', trigger: 'blur' },
                    { validator:function(rule,value,callback){
                            var reg =  /^[1-9]+[0-9]*]*$/ ;
                            if(value ==null || value =="null" || value ==""  ){
                                callback(new Error("请填写到访人数"));
                                mainDivVM.addVisitRecord.visitPeopleNum =null;

                            }else  if(value !=null && value !="null" && value !="" && !reg.test(value) ){
                                callback(new Error("请输入正整数"));
                                mainDivVM.addVisitRecord.visitPeopleNum =null;
                            }else{
                                callback();
                            }

                        }, trigger: 'change'}
                ]
            }
        },
        computed: {
            amountPerformance(){
                var aone = parseFloat(this.formSigning.amountReceived);
                var atwo = parseFloat(this.formSigning.firstToll);
                if(isNaN(aone)) aone = 0
                if(isNaN(atwo)) atwo = 0
                return aone + atwo
            },

            updateFormSigningAmountPerformance(){
                var aone = parseFloat(this.updateFormSigning.amountReceived);
                var atwo = parseFloat(this.updateFormSigning.firstToll);
                if(isNaN(aone)) aone = 0
                if(isNaN(atwo)) atwo = 0
                return aone + atwo
            },
        },
        methods: {
            getShopType(value){
                var param = {};
                param.id = value;
                axios.post('/busVisitRecord/getShortTypeByProjectId', param).then(function (response) {
                    console.log("###"+response.data.data);
                    if(mainDivVM.addVisitRecord.vistitStoreType){
                        mainDivVM.addVisitRecord.vistitStoreType ='';
                    }
                    mainDivVM.vistitStoreTypeArr= response.data.data;
                });
            },
            formatVisitTime(row){

                function dateFtt(fmt,date)
                { //author: meizz
                    var o = {
                        "M+" : date.getMonth()+1,                 //月份
                        "d+" : date.getDate(),                    //日
                        "h+" : date.getHours(),                   //小时
                        "m+" : date.getMinutes(),                 //分
                        "s+" : date.getSeconds(),                 //秒
                        "q+" : Math.floor((date.getMonth()+3)/3), //季度
                        "S"  : date.getMilliseconds()             //毫秒
                    };
                    if(/(y+)/.test(fmt))
                        fmt=fmt.replace(RegExp.$1, (date.getFullYear()+"").substr(4 - RegExp.$1.length));
                    for(var k in o)
                        if(new RegExp("("+ k +")").test(fmt))
                            fmt = fmt.replace(RegExp.$1, (RegExp.$1.length==1) ? (o[k]) : (("00"+ o[k]).substr((""+ o[k]).length)));
                    return fmt;
                }
                return dateFtt("yyyy-MM-dd hh:mm", new Date(row.vistitTime));
            },
            openEditVisitRecord(row){
                this.addVisitAble = false;//允许按钮点击
                // 打开编辑到访记录
                var param ={};
                param.id = clueId;
                axios.post('/busVisitRecord/echo',param).then(function (response) {
                    mainDivVM.addVisitRecord = response.data.data;
                    mainDivVM.addVisitRecord.clueId=clueId
                    mainDivVM.addVisitRecord.vistitTime = new Date()
                    mainDivVM.addVisitRecordDialogVisible = true;
                    mainDivVM.vistitStoreTypeArr= response.data.data.vistitStoreTypeArr;
                    mainDivVM.currentProvince(mainDivVM.addVisitRecord.signProvince)
                    mainDivVM.currentCity(mainDivVM.addVisitRecord.signCity)
                    mainDivVM.showNotSignReason(mainDivVM.addVisitRecord.isSign)
                });
            },
            editSign(row){
                // this.formSigning.clueId=row.clueId;
                // this.dialogFormSigningVisible = true;
                var param ={}
                param.id = clueId;
                axios.post('/businesssign/echo',param).then(function (response) {
                    mainDivVM.formSigning = response.data.data;
                    mainDivVM.formSigning.clueId=clueId;
                    mainDivVM.dialogFormSigningVisible = true;
                    mainDivVM.currentProvince(mainDivVM.formSigning.signProvince)
                    mainDivVM.currentCity(mainDivVM.formSigning.signCity)
                });
            },
            saveVisitRecord(){

                if(this.addVisitRecord.isSign==0&&!this.addVisitRecord.notSignReason){
                    mainDivVM.$message({
                        type: 'error', message: '请填写未签约原因！'});
                    return false;
                }

                var param = this.addVisitRecord;
                if(param.vistitTime){
                   param.vistitTime = new Date( param.vistitTime) 
                }                
                param.rebutTime = new Date( param.rebutTime)
                param.createTime = new Date( param.createTime)
                this.$refs['addVisitRecord'].validate((valid) => {
                    if (valid) {
                        mainDivVM.addVisitAble = true;
                        axios.post("/busVisitRecord/insert", param)
                            .then(function (response) {
                                if (response.data.code == 0) {
                                    mainDivVM.$message({type: 'success', message: '来访记录提交成功!',duration:2000,onClose:function(){
                                            mainDivVM.initList();
                                            mainDivVM.addVisitRecordDialogVisible = false;
                                            // mainDivVM.addVisitAble = false;//允许按钮点击
                                        //  跳转到我的客户页面
                                            window.location.href='/aggregation/businessMyCustomer/listPage';
                                        }});
                                } else {
                                    mainDivVM.$message.error(response.data.msg);
                                    mainDivVM.addVisitAble = false;
                                }
                            }).catch(function (error) {
                                mainDivVM.addVisitAble = false;
                                console.log(error);
                            });
                    } else {return false;}
                });
            },
            selectUpdateSigningType(pa1) { //是不是全款
                if( pa1=='1' ){
                    this.updateFormSigning.payType = '1';
                    this.isAllMoney = false;
                }else{
                    this.updateFormSigning.payType = '2';
                    this.isAllMoney = true;
                }
            },
            goEditSign(){
        	    if(signAuditStatus==1||signAuditStatus==2||signAuditStatus==0){
        	        if(signAuditStatus==0){
                        mainDivVM.$message.error("存在被驳回签约单");
                    }else if(signAuditStatus==1){
                        mainDivVM.$message.error("签约单正在审核中");
                        return  false;
                    }else{
                        mainDivVM.$message.error("签约单已经存在");
                        return  false;
        	        }
                }

                var param = this.addVisitRecord;
                param.rebutTime = new Date(param.rebutTime);
                param.createTime = new Date(param.createTime);
                this.$refs['addVisitRecord'].validate((valid) => {
                    if (valid) {
                        axios.post("/busVisitRecord/insert", param)
                            .then(function (response) {
                                if (response.data.code == 0) {
                                    mainDivVM.$message({type: 'success', message: '来访记录保存成功!',duration:2000,onClose:function(){
                                            mainDivVM.initList();
                                            mainDivVM.addVisitRecordDialogVisible = false;
                                            //  弹出签约单添加弹窗
                                            // mainDivVM.dialogFormSigningVisible = true;
                                            // mainDivVM.editSign(mainDivVM.addVisitRecord)
                                            mainDivVM.toSign(mainDivVM.addVisitRecord);
                                        }});
                                } else {
                                    mainDivVM.$message.error(response.data.msg);
                                }
                            }).catch(function (error) {console.log(error);});
                    } else {return false;}
                });
            },
            showNotSignReason(val){
                this.formSigning.notSignReason = "";
                if(val==0){
                    //  将隐藏换成元素添加 和 移除 ，这样的动态就会变得好看
                    document.getElementById("notSignReason").setAttribute("style","display:block")
                    // document.getElementById("goSignButton").setAttribute("style","visibility:hidden")
                    // document.getElementById("goSignButton").setAttribute("style","display:none")
                }else if(val==1){
                    document.getElementById("notSignReason").setAttribute("style","display:none")
                    // document.getElementById("goSignButton").setAttribute("style","visibility:visible")
                    //document.getElementById("goSignButton").setAttribute("style","display:block")
                }

            },
            submitForm(formName) {
                var param = this.formSigning;
                param.amountPerformance =  this.amountPerformance;
                // console.log("................................")
                // console.log(param)
                this.$refs[formName].validate((valid) => {
                    if (valid) {
                        this.addVisitAble = true;
                        axios.post("/businesssign/insert", param)
                            .then(function (response) {
                                if (response.data.code == 0) {
                                    mainDivVM.$message({type: 'success', message: '签约单保存成功!',duration:2000,onClose:function(){
                                            // mainDivVM.pager.pageNum = 1
                                            // mainDivVM.initList();
                                            mainDivVM.dialogFormSigningVisible = false;
                                            // mainDivVM.formSigning.clueId = "";
                                            mainDivVM.addVisitAble = false; 
                                            window.location.href='/aggregation/businessMyCustomer/listPage';
                                    }});
                                } else {
                                    mainDivVM.$message.error(response.data.msg);
                                    mainDivVM.addVisitAble = false;
                                }
                            }).catch(function (error) {mainDivVM.addVisitAble = false;console.log(error);});
                    } else {return false;}
                });
            },
            submitUpdateForm(formName) {
                var param = this.updateFormSigning;
                param.amountPerformance = this.updateFormSigningAmountPerformance;
                param.makeUpTime = new Date( param.makeUpTime)
                param.payTime = new Date( param.payTime)
                // 设置 clueid
                this.$refs[formName].validate((valid) => {
                    if (valid) {
                        this.addVisitAble = true; 
                        axios.post("/businesssign/update", param)
                            .then(function (response) {
                                if (response.data.code == 0) {
                                    mainDivVM.$message({type: 'success', message: '签约单更新成功!',duration:2000,onClose:function(){
                                            mainDivVM.dialogUpdateFormSigningVisible = false;
                                            mainDivVM.addVisitAble = false; 
                                            window.location.href='/aggregation/businessMyCustomer/listPage';
                                    }});
                                } else {
                                    mainDivVM.$message.error(response.data.msg);
                                    mainDivVM.addVisitAble = false;
                                }
                            }).catch(function (error) {mainDivVM.addVisitAble = false;console.log(error);});
                    } else {return false;}
                });
            },
            editRebutSign(){
                var param ={};
                param.id = clueId
                axios.post('/businesssign/one',param).then(function (response) {
                    console.log(response)
                    if(null===response||response.data==null||response.data.code!='0'){
                        if(response.data.code!='0'){
                            mainDivVM.$message({message: response.data.msg, type: 'warning'});
                        }
                        return false;
                    }else{
                        mainDivVM.updateFormSigning =response.data.data;
                        mainDivVM.vistitStoreTypeArr = response.data.data.vistitStoreTypeArr;
                        if( mainDivVM.updateFormSigning){
                            if(mainDivVM.updateFormSigning.payType > 2){
                                if(mainDivVM.updateFormSigning.payType == 3){
                                    mainDivVM.isAllMoney = true;
                                }else{
                                    mainDivVM.isAllMoney = false;
                                }
                                mainDivVM.notEditRebutSign = true;
                                mainDivVM.payTypeSelect = false;
                                mainDivVM.payTypeArr = mainDivVM.payTypeArr1.slice(2,4)
                            }else{
                                if(mainDivVM.updateFormSigning.payType == 1){
                                    mainDivVM.isAllMoney = false;
                                }else{
                                    mainDivVM.isAllMoney = true;
                                }
                                mainDivVM.payTypeSelect = true;
                                mainDivVM.payTypeArr = mainDivVM.payTypeArr1.slice(0,2)
                            }


                            mainDivVM.currentProvince(mainDivVM.updateFormSigning.signProvince)
                            mainDivVM.currentCity(mainDivVM.updateFormSigning.signCity)
                        }
                        mainDivVM.dialogUpdateFormSigningVisible = true;
                    }
                })
            },
            currentProvince(selVal){
                param={};
                param.type="1";
                param.name=selVal;
                axios.post('/area/sysregion/querySysRegionByParam',param).then(function (response) {
                    mainDivVM.cityArr=response.data.data.data;
                });
            },
            currentCity(selVal){
                param={};
                param.type="2";
                param.name=selVal;
                axios.post('/area/sysregion/querySysRegionByParam',param).then(function (response) {
                    mainDivVM.districtArr=response.data.data.data;
                });
            },

            changeVisitProvince(selVal){
                mainDivVM.addVisitRecord.signCity = '';
                mainDivVM.addVisitRecord.signDistrict='';
                mainDivVM.districtArr=[]
                this.currentProvince(selVal);
            },
            changeVisitCity(selVal){
                mainDivVM.addVisitRecord.signDistrict=''
                this. currentCity(selVal);
            },

            resetForm(formName) {
                if( mainDivVM.$refs[formName]) {
                    mainDivVM.$refs[formName].resetFields();
                }
            },
            selectSigningType(pa1) { //是不是全款
                if( pa1=='1' ){
                    this.formSigning.payType = '1';
                    this.isAllMoney = false;
                }else{
                    this.formSigning.payType = '2';
                    this.isAllMoney = true;
                }
            },
            toSign(val){
                if(signAuditStatus=='0'){ // 当前签约单的状态 == 0 存在驳回签约单。
                    mainDivVM.editRebutSign(val)
                }else{
                    mainDivVM.editSign(val)
                }
            },
            initList(){
                var param = {};
                param.clueId = clueId
                param.busGroupId = busGroupId
                axios.post('/busVisitRecord/queryList',param).then(function (response) {
                    if(null===response||response.data==null||response.data.code!='0'){
                        if(response.data.code!='0'){
                            mainDivVM.$message({message: response.data.msg, type: 'warning'});
                        }
                        return false;
                    }else{
                        var dataList = response.data.data;
                        mainDivVM.showVisitAduitDatas = {}; // 赋值之前首先需要进行数据清空
                        // 首次到访
                        var first = [];
                        mainDivVM.showVisitAduitDatas.oneShow = true;
                        if(dataList.length>=1){
                            first.push(dataList[dataList.length-1])
                            mainDivVM.showVisitAduitDatas.one = first;
                            if(first[0].isSign==0){
                                mainDivVM.showVisitAduitDatas.oneNotSignReason = first[0].notSignReason;
                                mainDivVM.showVisitAduitDatas.oneNotSignShow = true;
                            }
                            if(first[0].rebutReason){
                                mainDivVM.showVisitAduitDatas.oneRebutReason = first[0].rebutReason;
                                mainDivVM.showVisitAduitDatas.oneRebutShow = true;
                            }
                        }

                        // 二次到访
                        var two = [];
                        if(dataList.length>=2){
                            two.push(dataList[dataList.length-2])
                            mainDivVM.showVisitAduitDatas.two = two;
                            mainDivVM.showVisitAduitDatas.twoShow = true;
                            if(two[0].isSign==0){
                                mainDivVM.showVisitAduitDatas.twoNotSignReason = two[0].notSignReason;
                                mainDivVM.showVisitAduitDatas.twoNotSignShow = true;
                            }
                            if(two[0].rebutReason){
                                mainDivVM.showVisitAduitDatas.twoRebutReason = two[0].rebutReason;
                                mainDivVM.showVisitAduitDatas.twoRebutShow = true;
                            }

                        }
                        // 多次到访
                        var three = []
                        if(dataList.length>=3){
                            three = dataList.slice(0,dataList.length-2)
                            mainDivVM.showVisitAduitDatas.three = three;
                            mainDivVM.showVisitAduitDatas.threeShow = true;
                            if(three[0].isSign==0){
                                mainDivVM.showVisitAduitDatas.threeNotSignReason = three[0].notSignReason;
                                mainDivVM.showVisitAduitDatas.threeNotSignShow = true;
                            }
                            if(three[0].rebutReason){
                                mainDivVM.showVisitAduitDatas.threeRebutReason = three[0].rebutReason;
                                mainDivVM.showVisitAduitDatas.threeRebutShow = true;
                            }
                        }
                    }
                })
            },
        },
        created(){
            this.initList();
            //  到访店铺类型 vistitStoreTypeArr
            // var param={};
            // param.groupCode="vistitStoreType";
            // axios.post('/dictionary/DictionaryItem/dicItemsByGroupCode',param).then(function (response) {
            //     mainDivVM.vistitStoreTypeArr=response.data.data;
            // });

            //初始化省份
            param={};
            param.type="0";
            axios.post('/area/sysregion/querySysRegionByParam',param).then(function (response) {
                mainDivVM.provinceArr=response.data.data.data;
            });


            //考察公司
            param={};
            axios.post('/aggregation/companyManager/listNoPage',param).then(function (response) {
                mainDivVM.companyArr=response.data.data;
            });

            //到访城市
            param = {};
            param.groupCode = "visitCity";
            axios.post('/dictionary/DictionaryItem/dicItemsByGroupCode', param).then(function (response) {
                mainDivVM.visitCityArr = response.data.data;
            });

        },
        mounted(){
            document.getElementById('mainDiv').style.display = 'block';
        }
    });

</script>
</body>
</html>